<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>修改文章</title>
    <link rel="stylesheet" href="/static/css/font.css">
    <link rel="stylesheet" href="/static/css/index.css">
    <script src="/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/js/index.js"></script>


</head>
<body>

<div class="layui-card">
    <form class="layui-form layui-form-pane" action="" id="add">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this">基本信息</li>
            </ul>

            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>文章标题
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="guidanceTitle" id="guidanceTitle"  autocomplete="off"
                                   class="layui-input" th:value="${guidance?.guidanceTitle}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>作者
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="guidanceAuthor" id="guidanceAuthor" autocomplete="off"
                                   class="layui-input"  th:value="${guidance?.guidanceAuthor}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>来源
                        </label>
                        <div class="layui-input-block">
                            <input type="text" name="guidanceReproduced" id="guidanceReproduced" autocomplete="off"
                                   class="layui-input"  th:value="${guidance?.guidanceReproduced}">
                        </div>
                    </div>
                    <div class="layui-form-item  layui-form-text">
                        <label  class="layui-form-label">
                            <span class="x-red">*</span>文章内容
                        </label>
                        <div class="layui-input-block">
                            <textarea   id="content"  class="layui-textarea"  th:text="${guidance?.guidanceContent}"></textarea>
                        </div>
                    </div>
                    <input type="hidden" id="guidanceId" th:value="${guidance?.guidanceId}">
                    <div class="layui-form-item">
                        <button class="layui-btn" type="button" lay-filter="add" lay-submit="" onclick="add()">
                            保存
                        </button>
                    </div>
                    <!--</form>-->
                    <div style="height:100px;"></div>
                </div>
            </div>

        </div>
    </form>
</div>

<script type="text/javascript">
    function add() {
        var guidanceId = $("#guidanceId").val();
        var guidanceTitle = $("#guidanceTitle").val();
        var guidanceAuthor = $("#guidanceAuthor").val();
        var guidanceReproduced = $("#guidanceReproduced").val();
        var guidanceContent = $("#content").val();
        $.ajax({
            url: 'updateGuides',
            method: 'post',
            async: false,
            data: {
                'guidanceId': guidanceId,
                'guidanceTitle': guidanceTitle,
                'guidanceAuthor': guidanceAuthor,
                'guidanceReproduced': guidanceReproduced,
                'guidanceContent': guidanceContent
            },
            success: function (data) {
                res = data;
                // alert(res)
            }
        });
        if (res == "1") {
            window.location.href = "findAllLoveGuides"
        } else {
            window.location.href = "toErrorPage"
        }
    }
</script>
</body>
</html>